#region Copyright RenGuiYou. All rights reserved.
//=====================================================
// NeatlyFrameWork
// Author:      RenGuiyou
// Feedback: 	mailto:750539605@qq.com
//=====================================================
#endregion

using System.Collections.Generic;

namespace Neatly.UI
{
    internal static class EmojiTuplePool
    {
        private static readonly List<EmojiTuple> m_TuplePool = new List<EmojiTuple>();

        public static EmojiTuple Create(int pos, string emoji)
        {
            if (m_TuplePool.Count>0)
            {
                var tuple = m_TuplePool[0];
                m_TuplePool.RemoveAt(0);
                tuple.pos = pos;
                tuple.emoji = emoji;
                return tuple;
            }
            return new EmojiTuple(pos, emoji);
        }

        public static void Release(EmojiTuple list)
        {
            m_TuplePool.Add(list);
        }

        public static void Release(List<EmojiTuple> list)
        {
            if (list==null) return;
            for (int i = list.Count-1; i >=0; i--)
            {
                Release(list[i]);
                list.RemoveAt(i);
            }
        }
    }

    class EmojiTuple
    {
        public int pos;
        public string emoji;
        public EmojiTuple(int p, string s)
        {
            pos = p;
            emoji = s;
        }

        public void SetPos(int p)
        {
            pos = p;
        }
    }
}
